import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)


/**
 *  title 标题
 *  isShow 显示/隐藏
 *    children [
 *        isShow:!false 不显示
 *    ]
 *  keepAlive 是否缓存
 */


const routes = [
  {
    path: '/',
    name: 'Home',
    redirect: '/login',
    meta: { title: '/', isShow: false, icon: 'false' }

  },
  //登录
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/Login/index'),
    meta: { title: '登录', isShow: false, icon: 'false' }

  },
  //首页
  {
    path: '/welcome',
    name: 'welcome',
    component: () => import('../views/Welcome/index'),
    meta: { title: '首页', isShow: false, icon: 'false' }
  },
  //用户管理
  {
    path: '/userManagement',
    name: 'userManagement',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/Welcome/index'),
    meta: { title: '用户管理', isShow: true, keepAlive: true, icon: 'yonghu' },
    redirect: '/users',
    children: [
      {
        path: '/users',
        name: 'users',
        component: () => import('../views/UserManagement/Users/index'),
        meta: { title: '用户列表', keepAlive: true }
      }
    ]
  },
  //权限管理
  {
    path: '/roleManagement',
    name: 'roleManagement',
    component: () => import('../views/Welcome/index'),
    meta: { title: '权限管理', isShow: true, keepAlive: true, icon: 'lifangti' },
    redirect: '/roles',
    children: [
      {
        path: '/roles',
        name: 'roles',
        component: () => import('../views/RoleManagement/Roles/index'),
        meta: { title: '角色列表', keepAlive: true },
      },
      {
        path: '/rights',
        name: 'rights',
        component: () => import('../views/RoleManagement/Rights/index'),
        meta: { title: '权限列表', keepAlive: true },
      }
    ]
  },
  //商品管理
  {
    path: '/goodsManagement',
    name: 'goodsManagement',
    component: () => import('../views/Welcome/index'),
    meta: { title: '商品管理', isShow: true, keepAlive: true, icon: 'bao' },
    redirect: '/goods',
    children: [
      {
        path: '/goods',
        name: 'goods',
        component: () => import('../views/GoodsManagement/Goods/index'),
        meta: { title: '商品列表', keepAlive: true },
      },
      {
        path: '/goods/add',
        name: 'goodsAdd',
        component: () => import('../views/GoodsManagement/AddGoods/index'),
        meta: { title: '添加商品', keepAlive: true, isShow: !false },
      },
      {
        path: '/params',
        name: 'params',
        component: () => import('../views/GoodsManagement/Params/index'),
        meta: { title: '分类参数', keepAlive: true },
      },
      {
        path: '/categories',
        name: 'categories',
        component: () => import('../views/GoodsManagement/Categories/index'),
        meta: { title: '商品分类', keepAlive: true },
      }

    ]
  },
  //订单管理
  {
    path: '/orderManagement',
    name: 'orderManagement',
    component: () => import('../views/Welcome/index'),
    meta: { title: '订单管理', isShow: true, keepAlive: true, icon: 'dingdan' },
    redirect: '/orders',
    children: [
      {
        path: '/orders',
        name: 'orders',
        component: () => import('../views/OrderManagement/Orders/index'),
        meta: { title: '商品列表', keepAlive: true },
      },

    ]
  },
  //数据统计
  {
    path: '/dataStatistics',
    name: 'dataStatistics',
    component: () => import('../views/Welcome/index'),
    meta: { title: '数据统计', isShow: true, keepAlive: true, icon: 'icon-test' },
    redirect: '/reports',
    children: [
      {
        path: '/reports',
        name: 'reports',
        component: () => import('../views/DataStatistics/Reports/index'),
        meta: { title: '数据报表', keepAlive: true },
      },

    ]
  },
  //404页面
  {
    path: '*',
    name: '404',
    component: () => import('../views/404page/index'),
    meta: { isShow: false },
  }
]

const router = new VueRouter({
  routes
})

export default router
